package cards.controller;

import cards.dao.UserDao;
import cards.entity.CardActivity;
import cards.entity.User;
import cards.service.CardActivityService;
import cards.util.HostHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.List;

@Controller
public class SearchController {
    @Autowired
    private CardActivityService cardActivityService;

    @Autowired
    private HostHolder localHost;

    @RequestMapping(path="/admin/{category}/search", method= RequestMethod.POST)
    public String searchParser(@PathVariable String category, String title, Model model) {
        List<CardActivity> cardActivityList = cardActivityService.findCardActivityByTitle(title);
        User user=localHost.getUser();
        model.addAttribute("user", user);
        model.addAttribute("topics", cardActivityList);
        model.addAttribute("header", "集卡活动配置页面");
        return category;
    }
}
